﻿package mortal.common.font
{
    import flash.text.*;
    import mortal.common.global.*;

    public class FontUtil extends Object
    {
        public static var defaultFont:FontName;
        public static var songtiFont:FontName;
        public static var xingkaiFont:FontName;
        public static var stXingkaiFont:FontName;
        public static var lishuFont:FontName;
        public static var _isHaveYahei:Boolean = false;
        public static var fontNameArray:Array;
        public static const EmbedNumberName:String = "number";
        public static const EmbedSkillName:String = "skillName";
        public static const EmbedTitleName:String = "title";
        public static const EmbedBaseName:String = "base";

        public function FontUtil()
        {
            return;
        }// end function

        public static function init() : void
        {
            var _loc_3:String = null;
            switch(ParamsConst.instance.proxyType)
            {
                case ProxyType.Vietnam:
                {
                    defaultFont = new SmallSizeFontName("Courier new");
                    songtiFont = new SmallSizeFontName("Courier new");
                    xingkaiFont = new SmallSizeFontName("Courier new");
                    stXingkaiFont = new SmallSizeFontName("Courier new");
                    lishuFont = new SmallSizeFontName("Courier new");
                    break;
                }
                case ProxyType.TW:
                {
                    defaultFont = new FontName("Times New Roman");
                    songtiFont = new FontName("宋体");
                    xingkaiFont = new FontName("宋体");
                    stXingkaiFont = new FontName("STXingkai");
                    lishuFont = new FontName("宋体");
                    break;
                }
                default:
                {
                    defaultFont = new FontName("微软雅黑,Microsoft YaHei,Microsoft YaHei UI,Microsoft YaHei Light,Microsoft YaHei UI Light,Times New Roman");
                    songtiFont = new FontName("宋体");
                    xingkaiFont = new FontName("STXingkai");
                    stXingkaiFont = new FontName("STXingkai");
                    lishuFont = new FontName("隶书");
                    break;
                    break;
                }
            }
            fontNameArray = new Array();
            var _loc_1:* = Font.enumerateFonts(true);
            var _loc_2:int = 0;
            while (_loc_2 < _loc_1.length)
            {
                
                _loc_3 = (_loc_1[_loc_2] as Font).fontName;
                fontNameArray.push(_loc_3);
                if (_loc_3 == "微软雅黑" || _loc_3 == "Microsoft YaHei" || _loc_3 == "Microsoft YaHei UI" || _loc_3 == "Microsoft YaHei Light" || _loc_3 == "Microsoft YaHei UI Light")
                {
                    _isHaveYahei = true;
                }
                _loc_2++;
            }
            return;
        }// end function

        public static function isHaveYahei() : Boolean
        {
            return _isHaveYahei;
        }// end function

        public static function get defaultName() : String
        {
            return defaultFont.fontName;
        }// end function

        public static function get songtiName() : String
        {
            return songtiFont.fontName;
        }// end function

        public static function get xingkaiName() : String
        {
            return xingkaiFont.fontName;
        }// end function

        public static function get stXingkaiName() : String
        {
            return stXingkaiFont.fontName;
        }// end function

        public static function get lishuName() : String
        {
            return lishuFont.fontName;
        }// end function

    }
}
